package com.itmg.tools.timer;

import java.util.List;
import java.util.TimerTask;

import com.itmg.cache.StaticInformationBean;
import com.itmg.dao.CacheDAO;
import com.itmg.dao.CacheDataDAO;
import com.itmg.dao.DataDAO;
import com.itmg.dao.model.DataModel;
import com.itmg.factory.DAOFactory;

public class UpdateCacheTimerTask extends TimerTask {
	
	CacheDAO cacheDAO = null;
	DataDAO dataDAO = null;
	CacheDataDAO cacheDataDAO = null;
	
	@Override
	public void run() {
		cacheDAO = DAOFactory.getCacheDAO();
		dataDAO = DAOFactory.getDataDAO();
		cacheDataDAO = DAOFactory.getCacheDataDAO();
		
		List<DataModel> listAll = null;
		try {
			listAll = cacheDAO.getCacheModelAll();
			dataDAO.saveData(listAll);
			cacheDAO.deleteAll();
			cacheDataDAO.deleteAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		StaticInformationBean.clearPageTable();
		StaticInformationBean.clearProductMd5();
		StaticInformationBean.clearTotal();
		
	}

}
